using Common.CustomEnums;
using IRepositories;
using IServices;
using System.Linq.Expressions;

namespace Services
{
    public partial class BaseService<TEntity> : IBaseService<TEntity> where TEntity : class, new()
    {
        public IBaseRepository<TEntity> repository;
        public BaseService(IBaseRepository<TEntity> repository)
        {
            this.repository = repository;
        }

        public bool Create(TEntity entity)
        {
            return repository.Create(entity);
        }

        public bool Create(IEnumerable<TEntity> entities)
        {
            return repository.Create(entities);
        }

        public TEntity CreateEntity(TEntity entity)
        {
            return repository.CreateEntity(entity);
        }

        public IEnumerable<TEntity> CreateEntity(IEnumerable<TEntity> entities)
        {
            return repository.CreateEntity(entities);
        }

        public bool Delete(object Id)
        {
            return repository.Delete(Id);
        }

        public bool Delete(IEnumerable<object> Ids)
        {
            return repository.Delete(Ids);
        }

        public bool Delete(Expression<Func<TEntity, bool>> expression)
        {
            return repository.Delete(expression);
        }

        public bool Update(TEntity entity)
        {
            return repository.Update(entity);
        }

        public bool Update(IEnumerable<TEntity> entities)
        {
            return repository.Update(entities);
        }

        public TEntity? Query(object Id)
        {
            return repository.Query(Id);
        }

        public IQueryable<TEntity> Query()
        {
            return repository.Query();
        }

        public IQueryable<TEntity> Query(Expression<Func<TEntity, bool>> whereExpression)
        {
            return repository.Query(whereExpression);
        }

        public IQueryable<TEntity> Query<TOrder>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TOrder>> orderExpression, SortOrder order = SortOrder.Ascending)
        {
            return repository.Query(whereExpression, orderExpression, order);
        }

        public IQueryable<TEntity> Query<TOrder>(Expression<Func<TEntity, bool>>? whereExpression = null, Expression<Func<TEntity, TOrder>>? orderExpression = null, SortOrder order = SortOrder.Ascending, int pageIndex = 0, int pageSize = 0)
        {
            return repository.Query(whereExpression, orderExpression, order, pageIndex, pageSize);
        }

        public TEntity? QueryWhere(Expression<Func<TEntity, bool>> whereExpression)
        {
            return repository.QueryWhere(whereExpression);
        }


    }
}
